#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "graph.h"

#define CAPACITY 20
pGraph setUpGraph();

int main(int argc, char** argv) {
	pGraph graph = setUpGraph();
	// printGraph(graph);
	// printf("--------------------\n");

	// topSort(graph);
	// printf("--------------------\n");


	// unWeightShortPath(graph, 3);
	// printf("--------------------\n");


	weightShortPath(graph, 3);
	printf("--------------------\n");


	// printGraph(graph);
	// printf("--------------------\n");

	// dropVertex(graph, 4);
	// printGraph(graph);
	// printf("--------------------\n");

	return 0;
}

static int vertex[] = {1, 2, 3, 4, 5, 6, 7};
struct _edge {int sid; int did; float w;}; // src id -> dst id
struct _edge edges[] = {
	// v1
	{.sid = 1, .did = 2, .w = 2},
	{.sid = 1, .did = 4, .w = 1},
	// v2
	{.sid = 2, .did = 4, .w = 3},
	{.sid = 2, .did = 5, .w = 10},
	// v3
	{.sid = 3, .did = 6, .w = 5},
	{.sid = 3, .did = 1, .w = 4},
	// v4
	{.sid = 4, .did = 3, .w = 2},
	{.sid = 4, .did = 5, .w = 1},
	{.sid = 4, .did = 6, .w = 4},
	{.sid = 4, .did = 7, .w = 4},
	// v5
	{.sid = 5, .did = 7, .w = 6},
	// v6
	{.sid = 6, .did = 5, .w = 2},
	// v7
	{.sid = 7, .did = 6, .w = 1}

};
pGraph setUpGraph() {
	int vLen = sizeof(vertex) / sizeof(vertex[0]);
	assert( vLen <= CAPACITY);

	pGraph graph = initGraph(CAPACITY);

	int i;
	// add vertex
	for (i = 0; i < vLen; i++)
		addVertex(graph, vertex[i]);

	// add edges
	int eLen = sizeof(edges) / sizeof(edges[0]);
	for (i = 0; i < eLen; i++) {
		struct _edge edge = edges[i];
		addEdge(graph, edge.sid, edge.did, edge.w);
	}
	return graph;
}